﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace TransportAbstractionLibrary
{
    public sealed class BinaryHelper
    {
        //test this function so that the last bytes are allways checked
        public static unsafe bool CompareByte(byte[] array1, byte[] array2)
        {
            if (array1 == null)
            {
                throw new ArgumentNullException("array1");
            }
            if (array2 == null)
            {
                throw new ArgumentNullException("array2");
            }
            if (array1.Length != array2.Length)
            {
                return false;
            }
            fixed (byte* pArray1 = array1, pArray2 = array2)
            {
                uint* p1 = (uint*)pArray1;
                uint* p2 = (uint*)pArray2;
                for (int i = 0; i < array1.Length / 4; i++)
                {
                    if (p1[i] != p2[i])
                    {
                        return false;
                    }
                }
            }
            return true;
        }
    }
}
